package pzl.com.simplechart;

import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;

import java.util.Random;

import pzl.com.library.chart.BaseChart;
import pzl.com.library.chart.LineChart;
import pzl.com.library.data.DataList;
import pzl.com.library.data.Entry;

public class LineChartActivity extends AppCompatActivity {
    private LineChart lineChart;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_line_chart);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        lineChart = (LineChart) findViewById(R.id.lc);
        lineChart.setDataDrawAreaHeight(200);
        lineChart.setDataDrawAreaWidth(250);
        lineChart.debugDraw = true;
        lineChart.setScrollType(BaseChart.SCROLL_TYPE_ENABLE_X);

        Random r = new Random();
        DataList dataList1 = new DataList();
        dataList1.setPrimaryColor(Color.BLUE);
        int xPx = 0;
        for (int i = 0; i <= 100; i++) {
            //int x = -600 + r.nextInt(1200);
            int yPx = 0 + r.nextInt(900);
            xPx += 20;
            Entry e = new Entry();
            e.setxPX(xPx);
            e.setyPX(yPx);
            dataList1.add(e);
        }

        DataList dataList2 = new DataList();
        dataList2.setPrimaryColor(Color.DKGRAY);
        xPx = 0;
        for (int i = 0; i <= 50; i++) {
            //int x = -600 + r.nextInt(1200);
            int yPx = 0 + r.nextInt(900);
            xPx += 20;
            Entry e = new Entry();
            e.setxPX(xPx);
            e.setyPX(yPx);
            dataList2.add(e);
        }

        lineChart.addDataSet("1", dataList1);
        lineChart.addDataSet("2", dataList2);
        lineChart.invalidate();
    }

}
